<?php
include_once($project_path.'/class/fw/listGroup.php5');

class fwListGroupData extends fwListGroup
{
	public $datas=array();
	
	public function getDatasLength()
	{
		return count($this->datas);
	}
	
	public function sortDatas($field=null)
	{
		if($field!==null)
		{
			$this->addOrderClose($field);
		}
		usort($this->datas, array(&$this, 'compareValues'));
	}
	
	function compareValues($a, $b)
	{
		foreach($this->order as $order)
		{
			$al = strtolower($a[$this->fieldsIndex[$order['name']]['data_field']]);
        	$bl = strtolower($b[$this->fieldsIndex[$order['name']]['data_field']]);
        	if ($al < $bl)
        	{
        		if($order['sens'] == 'ASC') return -1;
        		else return 1;
        	}
            elseif ($al > $bl)
        	{
        		if($order['sens'] == 'ASC') return 1;
        		else return -1;
        	}
		}
        return 0;
    }
	
	public function getDatas($index, $length)
	{
		return array_slice($this->datas, $index, $length);
	}
}
?>